﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Web.Services;
using Newtonsoft.Json;

namespace PropertyAppraisal.SystemManage
{
    public partial class XiTongRoles : System.Web.UI.Page
    {

        private static BLL.RolesBll rbll = new BLL.RolesBll();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 显示角色列表
        /// </summary>
        /// <returns></returns>
        [WebMethod]
        public static string showRole()
        {
            var result = rbll.Show();
            return JsonConvert.SerializeObject(result);
        }

        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            Model.SysRoles r = new Model.SysRoles();
            r.roles_Name = txtName.Text;
            r.roles_Remarks = txtRamark.Text;
            r.roles_IsState = 0;
            r.roles_CreateTime = DateTime.Now;
            r.roles_CreatePeople = "小黑";
            var result = rbll.Add(r);
            if (result)
            {
                Response.Write("<script>alert('添加成功')</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败')</script>");
            }
        }

        /// <summary>
        /// 删除角色
        /// </summary>
        /// <returns></returns>
        [WebMethod]
        public static int DelRole(int roleid)
        {
            var id = roleid;
            Model.SysRoles r = new Model.SysRoles();
            r.roles_Id = id;
            var result = rbll.DelRole(r);
            if (result)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }

    }
}